package com.diankangwo.factory.controller;


import com.diankangwo.common.annotation.SysLog;
import com.diankangwo.common.utils.PageUtils;
import com.diankangwo.common.utils.Query;
import com.diankangwo.common.utils.R;
import com.diankangwo.factory.entity.TdOnlinepaylog;
import com.diankangwo.factory.service.TdOnlinePayLogService;
import com.diankangwo.sys.controller.AbstractController;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 支付记录controller
 */
@RestController
@RequestMapping("/fac/onlinePayLog")
public class TdOnlinePayLogController extends AbstractController {

    @Autowired
    private TdOnlinePayLogService tdOnlinePayLogService;


    /**
     * 根据条件所有支付记录
     */
    @ApiOperation(value = "根据条件所有支付记录", notes = "")
    @ApiImplicitParam(name = "params", value = "查询条件", required = true, dataType = "Map<String,Object>")
    @RequestMapping("/list")
    @RequiresPermissions("fac:onlinePayLog:list")
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Query query = new Query(params);
        //获取对记录
        List<TdOnlinepaylog> tdOnlinepaylog = tdOnlinePayLogService.queryList(query);
        int total = tdOnlinePayLogService.queryTotal(query);
        PageUtils pageUtil = new PageUtils(tdOnlinepaylog, total, query.getLimit(), query.getPage());
        return R.ok().put("page", pageUtil);
    }

    /**
     * 查询单个支付记录详情
     */
    @ApiOperation(value = "查询单个支付记录详情", notes = "")
    @ApiImplicitParam(name = "id", value = "支付记录ID", required = true, dataType = "int")
    @SysLog("查询单个商品详情")
    @RequestMapping("/findById")
    @RequiresPermissions("fac:onlinePayLog:findById")
    public R findById(int id) {
        TdOnlinepaylog tdOnlinepaylog = tdOnlinePayLogService.selectByPrimaryKey(id);
        return R.ok().put("onlinepaylog", tdOnlinepaylog);
    }

}
